package com.bolang.onlycode.demo.MyThread;

import java.util.HashMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;

/**
 * @Auther: bl_xueld
 * @Date: 2021/12/23 09:05
 * @Description:
 */
public class Test {
   public static Thread t1 ;
    public static void main(String[] args)  {
        OneThread thread =new OneThread();
        thread.start();
//
//         t1 =new Thread(new print(),"t1");
//        t1.start();
//
//
//            System.out.println("线程醒过来了方法下一行被执行了");
//
//        System.out.println("main方法全部运行完毕");






    }
    static class print implements Runnable{
        @Override
        public void run() {
            try {

                String  str="";
                String s = "11,22,33";
                System.out.println(s.substring(2));
                char[] split = s.toCharArray();
                for (char s1 : split) {
                    System.out.println(s1);
                }
                str =str+ s;
                System.out.println("t1线程已经启动，即将中断主线程");
                LockSupport.unpark(t1);
                t1.interrupt();
                LockSupport.park(t1);
                System.out.println("t1线程没有成功park");
                Thread.interrupted();
                LockSupport.unpark(t1);
                LockSupport.park(t1);
                System.out.println("t1线程没有park,因为中断期间park没有消耗凭证");
           TimeUnit.SECONDS.sleep(4);
                System.out.println("t1线程睡眠结束");
            } catch (Exception e) {
                System.out.println("t1线程开始响应中断，抛出中断异常说明成功中断");
            }
            System.out.println("t1线程run方法执行结束");

        }
    }
//    public static void main(String[] args) {
//        for (int i = 0; i < 50; i++) {
//            new Test4Thread().start();
//        }
//    }

}

//    int ticket = 10;
//    String str="0";
//    String.valueOf(Integer.parseInt(str)+1)
//    @Override
//    public void run() {
//
//
//        while(true){
//            if(ticket>0){
//                try {
//                    Thread.currentThread();
//                    Thread.sleep(100);
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                }
//                System.out.println(Thread.currentThread().getName()+"卖。。。"+ticket--);
//            }else {
//                break;
//            }
//
//        }
//
//    }






